package edu.auctionmart



import edu.auctionmart.Preferences;
import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Preferences)
class PreferencesTests {

    void testPreferences() {
		
		
		Preferences testPreference = new Preferences(smsShouldAlert: true, ivrShouldAlert: true, emailShouldAlert: true)
		testPreference.validate()
		assert(testPreference.hasErrors() == false)
		
		testPreference = new Preferences(smsShouldAlert: false, ivrShouldAlert: false, emailShouldAlert: false)
		testPreference.validate()
		assert(testPreference.hasErrors() == false)
		
		testPreference = new Preferences(smsShouldAlert: true, ivrShouldAlert: true, emailShouldAlert: true, smsNumber: 2074503879, ivrNumber: 2074503879, emailAlertAddress: "rhgillen@gmail.com")
		testPreference.validate()
		assert(testPreference.hasErrors() == false)
		
		testPreference = new Preferences(smsShouldAlert: true, ivrShouldAlert: true, emailShouldAlert: true, smsNumber: 207879, ivrNumber: 2074503879, emailAlertAddress: "rhgillen@gmail.com")
		testPreference.validate()
		assert(testPreference.hasErrors() == true)
		
		testPreference = new Preferences(smsShouldAlert: true, ivrShouldAlert: true, emailShouldAlert: true, smsNumber: 2074503879, ivrNumber: 207, emailAlertAddress: "rhgillen@gmail.com")
		testPreference.validate()
		assert(testPreference.hasErrors() == true)
		
		testPreference = new Preferences(smsShouldAlert: true, ivrShouldAlert: true, emailShouldAlert: true, smsNumber: 2074503879, ivrNumber: 2074503879, emailAlertAddress: "rhgillengmail.com")
		testPreference.validate()
		assert(testPreference.hasErrors() == true)
  
    }
}
